package rattlesnake.callback.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import rattlesnake.callback.config.interceptor.UniqueInterceptor;
import rattlesnake.callback.core.cache.CacheManager;

/**
 * @Package: rattlesnake.callback.config
 * @Description: 配置拦截器
 * @author: liuxin
 * @date: 17/4/10 下午1:54
 */
//@Configuration
public class MyInterceptorConfig extends WebMvcConfigurerAdapter {
//    @Autowired
    CacheManager cacheManager;
//    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        UniqueInterceptor uniqueInterceptor=new UniqueInterceptor();
        uniqueInterceptor.setCacheManager(cacheManager);
       registry.addInterceptor(uniqueInterceptor).addPathPatterns("/**");
    }

//    @Bean
    public CacheManager getCacheManager(CacheManager cacheManager){
        return cacheManager;
    }
}
